package kr.or.kosta.otr.persistence.report;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.annotation.Resource;

import kr.or.kosta.otr.vo.ReportVO;

import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;
@Repository("ReportDao")
public class ReportDaoImpl implements ReportDao{
	@Resource(name="sqlMapClient")
	private SqlMapClient sqlMapClient;
	
	
	@Override
	public int writeReport(ReportVO vo) throws SQLException {
		return (int) sqlMapClient.insert("Report.writeReport", vo);
	}

	@Override
	public void deleteReport(int reportId) throws SQLException {
		sqlMapClient.delete("Report.deleteReport", reportId);
	}

	@Override
	public ReportVO getOneReport(int reportId) throws SQLException {
		return (ReportVO)sqlMapClient.queryForObject("Report.getOneReport", reportId);
	}

	@Override
	public ArrayList<ReportVO> getAllReprot(String adminId) throws SQLException {
		return (ArrayList<ReportVO>)sqlMapClient.queryForList("Report.getAllReprot",adminId);
	}
	@Override
	public ArrayList<ReportVO> getAllSendReprot(String userId) throws SQLException {
		return (ArrayList<ReportVO>)sqlMapClient.queryForList("Report.getAllSendReprot",userId);
	}
	@Override
	public void checkReport(HashMap<String, Object> map) throws SQLException {
		// TODO Auto-generated method stub
		sqlMapClient.update("Report.checkReport",map);
	}

	@Override
	public int getReportCount(String adminId) throws SQLException {
		// TODO Auto-generated method stub
		return (int) sqlMapClient.queryForObject("Report.getReportCount",adminId);
	}

	@Override
	public ArrayList<ReportVO> getAllReprotPage(HashMap<String, Object> map)
			throws SQLException {
		// TODO Auto-generated method stub
		return (ArrayList<ReportVO>)sqlMapClient.queryForList("Report.getAllReprotPage",map);
	}

	@Override
	public int getAllReprotTotal(String adminId) throws SQLException {
		// TODO Auto-generated method stub
		return (int) sqlMapClient.queryForObject("Report.getAllReprotTotal",adminId);
	}

}
